package com.aspose.cells.a.d;

public class zfh extends zff {
   private byte[] c;
   private com.aspose.cells.b.a.d.zm d;
   private int e = 0;
   private static final com.aspose.cells.b.c.a.za f = new com.aspose.cells.b.c.a.za(new String[]{"gIFx", "gIFg"});

   public zfh(byte[] var1, com.aspose.cells.b.a.d.zm var2) {
      this.c = var1;
      this.d = var2;
   }

   public void a(com.aspose.cells.b.a.d.zm var1) throws Exception {
      this.b[0] = -119;
      this.b[1] = 80;
      this.b[2] = 78;
      this.b[3] = 71;
      this.b[4] = 13;
      this.b[5] = 10;
      this.b[6] = 26;
      this.b[7] = 10;
      this.d.b(this.b, 0, this.b.length);
      super.a(var1);
      switch(this.e) {
      case 0:
         this.a("gIFx");
         ++this.e;
         this.a("gIFg");
         ++this.e;
         this.e();
         ++this.e;
         break;
      case 1:
         this.a("gIFg");
         ++this.e;
         this.e();
         ++this.e;
         break;
      case 2:
         this.e();
         ++this.e;
      }

   }

   protected boolean a() throws Exception {
      if (this.e > 2) {
         this.d();
         return true;
      } else {
         if (this.b[4] == 73 && this.b[5] == 72 && this.b[6] == 68 && this.b[7] == 82) {
            this.d();
            this.a("gIFx");
            ++this.e;
         } else if (this.b[4] == 98 && this.b[5] == 75 && this.b[6] == 71 && this.b[7] == 68) {
            this.d();
            switch(this.e) {
            case 0:
               this.a("gIFx");
               ++this.e;
               this.a("gIFg");
               ++this.e;
               break;
            case 1:
               this.a("gIFg");
               ++this.e;
            }
         } else if (this.b[4] == 99 && this.b[5] == 77 && this.b[6] == 80 && this.b[7] == 80) {
            switch(this.e) {
            case 0:
               this.a("gIFx");
               ++this.e;
               this.a("gIFg");
               ++this.e;
               break;
            case 1:
               this.a("gIFg");
               ++this.e;
            }

            this.d();
         } else if (this.b[4] == 73 && this.b[5] == 68 && this.b[6] == 65 && this.b[7] == 84) {
            switch(this.e) {
            case 0:
               this.a("gIFx");
               ++this.e;
               this.a("gIFg");
               ++this.e;
               this.d();
               this.e();
               ++this.e;
               break;
            case 1:
               this.a("gIFg");
               ++this.e;
               this.d();
               this.e();
               ++this.e;
               break;
            case 2:
               this.d();
               this.e();
               ++this.e;
            }
         } else {
            this.d();
         }

         return true;
      }
   }

   private void d() throws Exception {
      this.d.b(this.b, 0, this.b.length);
      int var1 = this.b() + 4;

      byte[] var2;
      int var3;
      for(var2 = new byte[var1]; var1 > 0; var1 -= var3) {
         var3 = this.a.a(var2, var2.length - var1, var1);
         if (var3 <= 0) {
            return;
         }
      }

      this.d.b(var2, 0, var2.length);
   }

   private void a(String var1) throws Exception {
      byte[] var2;
      switch(f.a(var1)) {
      case 0:
         var2 = new byte[]{0, 0, 0, 14, 103, 73, 70, 120, 78, 69, 84, 83, 67, 65, 80, 69, 50, 46, 48, 1, 0, 0, 36, 78, -104, 80};
         break;
      case 1:
         var2 = new byte[]{0, 0, 0, 4, 103, 73, 70, 103, 2, 0, 0, 14, -47, 61, -31, -63};
         break;
      default:
         return;
      }

      this.d.b(var2, 0, var2.length);
   }

   private void e() throws Exception {
      com.aspose.cells.a.e.zh var1 = new com.aspose.cells.a.e.zh();
      this.a(this.c.length + 11, this.d);
      byte[] var2 = new byte[]{109, 115, 79, 71, 77, 83, 79, 70, 70, 73, 67, 69, 57, 46, 48};
      this.d.b(var2, 0, var2.length);
      var1.a(var2);
      this.d.b(this.c, 0, this.c.length);
      var1.a(this.c);
      this.a((int)((long)var1.a() & 4294967295L), this.d);
   }

   private void a(int var1, com.aspose.cells.b.a.d.zm var2) throws Exception {
      byte[] var3 = com.aspose.cells.b.a.zc.a(var1);

      for(int var4 = 3; var4 > -1; --var4) {
         var2.a(var3[var4]);
      }

   }
}
